package com.cnbot.canapp.listener.base;


import com.dc.android_can.can.CanDataType;

/**
 * @project RobotSDKApi
 * @author ww
 * @date 2018/5/8
 * @description 支持多种串口指令的基类
 * @version ${PROJECT_VERSION}
 */

public abstract class MultiSerialItem<T> implements IBaseCANDataResultListener, IRelease {

	protected String TAG = getClass().getSimpleName();

	/**
	 * 当前支持的指令类型
	 */
	protected int[] types;

	protected T mListener;

	protected CanDataType canDataType;

	public MultiSerialItem(int... types) {
		this.types = types;
	}

	public MultiSerialItem(T l, int... types) {

		this.types = types;

		mListener = l;
	}

	@Override
	public void onCanReceived(int id, CanDataType data) {
		canDataType = data;
		onOrderDispatch(id);
	}

	public abstract void onOrderDispatch(int id);

	@Override
	public void onRelease() {
		types = null;
		mListener = null;
		canDataType = null;
		TAG = null;
	}
}
